#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e5 + 5;

int a[N], s[N], n, k;
ll m;

bool check(int mid) { 
    int l = 0;
    ll sum=0;
    for(int i = 1; i <= n; i++) s[i] = s[i-1] + (a[i] >= mid);
    for(int i = k; i <= n; i++){
        while(s[i]-s[l] >= k) l++;
        sum += l;
    }
    return sum >= m;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int l = 1, r = 1;
        cin >> n >> k >> m;
        if (n < k) {
            cout << 0 << endl;
            continue;
        }
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            r = max(r, a[i]);
        }
        while (l <= r) {
            int mid = l + (r - l) / 2;
            if (check(mid))
                l = mid + 1;
            else
                r = mid - 1;
        }
        cout<<r<<endl;
    }

    return 0;
}